/**
 * @author scylla
 * @version V1.0
 * @Project echo-java-base
 * @Title 偶数生成器
 * @Description *
 * @Package concurrent.mthread.bf
 * @Since 2021/8/12 5:08 下午
 */
package concurrent.mthread.bf;

public class SynchronizedEvenGenerator extends IntGenerator {

    private int currentEvenValue = 0;

    @Override
    public synchronized int next() {
        ++currentEvenValue;//Synchronized protected
        Thread.yield();
        ++currentEvenValue;
        return currentEvenValue;
    }

    public static void main(String[] args) {
        EvenChecker.test(new SynchronizedEvenGenerator());
    }
}
